package com.v.service;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ImportResource;

@SpringBootApplication
@MapperScan("com.v.dao.mapper")
public class ServiceApplication {

    public static void main(String[] args) {

        // spring.profiles.active设置为local，这样在控制台可以打印日志，在测试或者生产环境不要在控制台打印日志
//        System.setProperty("spring.profiles.active", "local");
        System.setProperty("spring.profiles.active", System.getProperty("env"));

        ApplicationContext applicationContext = null;
        boolean success = true;
        try {
            applicationContext = SpringApplication.run(ServiceApplication.class,
                    args);
        } catch (Exception e) {
            success = false;
            e.printStackTrace();
            System.err.println("**********************启动失败****************" + e.getMessage());
        }
        if (success) {
            ApplicationInfo info = applicationContext
                    .getBean(ApplicationInfo.class);
            System.out.println("**********************启动成功:{}****************" + info.toString());
        } else {
            System.exit(0);
        }

    }
}
